package com.example.demo.controller;

import java.util.HashMap;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.model.Person;

/**
* @comments Hello world Controller
* @author  zg
* @date 2018年8月22日
*/
@Controller
@RequestMapping("chapter1/1/")
public class Chapter1_1Controller {
	
	@ResponseBody
	@RequestMapping("hello")
	public String hello() {
		
		return "Hello world! Spring Boot.";
	}
	
	@ResponseBody
	@RequestMapping("hello1")
	public Person hello1(Person person) {
		
		return person;
	}
	
	@ResponseBody
	@RequestMapping("hello2")
	public Object hello2(@RequestParam HashMap<String,String> param) {
		
		return param;
	}
	
	/**
	 * 接受json数据
	 * @param person
	 * @return
	 */
	@ResponseBody
	@RequestMapping("hello3")
	public Object hello2(@RequestBody Person person) {
		System.out.println("hello3:" + person.getName() + "," + person.getAge() + "," + person.getGender());
		return person;
	}
	
}
